﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DTO;
using ModuleDALCore;
using System.Data;
namespace DAL
{
    public class LOAIVATLIEUDAO:DALBase
    {
        public LOAIVATLIEUDAO()
        {
            this.OpenConnect();
        }
        private DataTable dt;
        private string _SpName;

        public string SpName
        {
            get { return "SPLOAIVATLIEU"; }
            set { _SpName = value; }
        }
        public DataTable GetListLVL()
        {
            dt = new DataTable();
            try
            {

                dt = DBManager.Intance.ExecuteDataTable(SpName, ConvertClassToArray.GetParamName(new LOAIVATLIEU(), null), ConvertClassToArray.GetValues(new LOAIVATLIEU(), 0));
                return dt;
            }
			catch { return null; }
        }
        public List<LOAIVATLIEU> GetListLVLL()
        {
            dt = new DataTable();
            List<LOAIVATLIEU> dsvt = new List<LOAIVATLIEU>();
            try
            {
                dt = DBManager.Intance.ExecuteDataTable(SpName, ConvertClassToArray.GetParamName(new LOAIVATLIEU(), null), ConvertClassToArray.GetValues(new LOAIVATLIEU(), 0));
                dsvt = (List<LOAIVATLIEU>)ConvertDatatableToList.ConvertTo<LOAIVATLIEU>(dt);
            }
			catch { return null; }
            return dsvt;
        }
        public String CreatenewId()
        {
            try
            {
                return "LVL" + DBManager.Intance.ExecuteNonQuery(SpName, ConvertClassToArray.GetParamName(new LOAIVATLIEU(), null), ConvertClassToArray.GetValues(new LOAIVATLIEU(), 1));

            }
			catch { return null; }
        }
        public bool INSERT(LOAIVATLIEU cv)
        {

            try
            {
                return (DBManager.Intance.ExecuteNonQuery(SpName, ConvertClassToArray.GetParamName(cv, null), ConvertClassToArray.GetValues(cv, 2)) == 1);

            }
            catch { return false; }
        }
        public bool UPDATE(LOAIVATLIEU cv)
        {

            try
            {
                return (DBManager.Intance.ExecuteNonQuery(SpName, ConvertClassToArray.GetParamName(cv, null), ConvertClassToArray.GetValues(cv, 3)) == 1);

            }
			catch { return false; }
        }
        public bool DELETE(LOAIVATLIEU cv)
        {

            try
            {
                return (DBManager.Intance.ExecuteNonQuery(SpName, ConvertClassToArray.GetParamName(cv, null), ConvertClassToArray.GetValues(cv, 4)) == 1);

            }
			catch { return false; }
        }
    }
}
